<?php

namespace Xrfg\Wallet\CollectERC\Console;

use App\Models\Coin;
use Illuminate\Console\Command;
use Xrfg\Wallet\CollectERC\Services\ETHWallet;

class DestroyErc extends Command
{
    protected $signature = 'destroy_erc {coin_name} {number}';

    protected $description = '销毁ERC';

    // 币种名称
    protected $coin_name;

    // 销毁数量
    protected $number;

    // 归集配置
    protected $config;

    protected $rpc;

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        $this->coin_name = $this->argument('coin_name');
        $this->number = $this->argument('number');

        $coin = Coin::where('name', $this->coin_name)->first();
        if (!$coin) {
            return;
        }

        $this->config = config('wallet.eth.collect_coins')[$this->coin_name];
        $this->rpc = new ETHWallet($this->config);
        $this->rpc->destroyErc($this->number);

    }
}
